import 'package:flutter/material.dart';

List<String> logList = <String>[];

void printLog(String log) {
  print("printLog: $log");
  logList.add(log);
}

void printLogs(List<String> log) {
  print("printLogs: $log");
  logList.addAll(log);
}

void clearLog() {
  logList.clear();
}

class StringListPage extends StatefulWidget {

  const StringListPage({super.key});

  @override
  State<StatefulWidget> createState() => _StringListPageState();
}

class _StringListPageState extends State<StringListPage> {

  @override
  Widget build(BuildContext context) {
    final List<String> stringItems = logList;
    return Scaffold(
      body: ListView.builder(
        itemCount: stringItems.length,
        itemBuilder: (BuildContext context, int index) {
          return Container(
              padding: const EdgeInsets.fromLTRB(4, 2, 4, 2),
              width: double.infinity,
              alignment: Alignment.centerLeft,
              child: Text(stringItems[index]));
        },
      ),
      // floatingActionButton: FloatingActionButton(
      //   onPressed: () {
      //     print('++++ log info from dart');
          
      //     setState(() {
      //       clearLog();
      //     });
      //   },
      //   child: const Icon(Icons.play_arrow),
      // ),
    );
  }
}
